import { tableOption } from './closeTrade.config.js'
import search from './../search/search.js';
import { fetchList,subbigdecimal } from '@/api/shop/order/SuperCoffeeBar.js'

export default {
    name: "closeTrade",
    mixins: [search],
    components: {
    },
    data() {
        return {
            tableOption,
            loading: false,
            loadData: [],
            page: {
                current: 1,
                total: 0,
                size: 10
            },
            searchForm: {},
            bigdecimal:0
        }
    },
    methods: {
        getList(searchForm, page) {
            if (searchForm) {
                this.searchForm = searchForm
            }
            if (page) {
                this.page.current = page
            }
            fetchList(Object.assign({ shopId: this.$store.getters.userInfoMessage.shopId, orderStatus: '04' }, this.searchForm, this.page)).then(val => {
                let data = val.data
                this.page = {
                    total: data.total,
                    size: data.size,
                    current: data.current
                }
                this.$emit("trigger")
                this.loadData = data.records
            })
            subbigdecimal(Object.assign({ shopId: this.$store.getters.userInfoMessage.shopId, orderStatus: '04',businessType:'02' }, this.searchForm, this.page)).then(val=>{  //流水总金额
                this.bigdecimal = val.data
            })
        },
        onShowSizeChange(current, size) {
            console.log(current, size)
            this.page.current = current
            this.page.size = size
            this.getList()
        },
        orderDetails(record) {
            console.log(record)
            this.$router.push({ path: "/shop/order/SuperCoffeeBar/details", query: { subOrderId: record.subOrderId } })
        },
    },
    filters: {
        orderStatus(val) {
            let obj = ''
            switch (val) {
                case '00':
                    obj = '支付成功'
                    break;
                case '01':
                    obj = '支付失败'
                    break;
                case '02':
                    obj = '待支付'
                    break;
                case '03':
                    obj = '支付中'
                    break;
                case '04':
                    obj = '支付关闭、作废'
                    break;
                case '05':
                    obj = '退款中'
                    break;
                case '06':
                    obj = '退款完成'
                    break;

                case '07':
                    obj = '退款失败'
                    break;
                case '08':
                    obj = '待派单'
                    break;
                case '09':
                    obj = '服务中'
                    break;
                case '10':
                    obj = '已拒单'
                    break;
                case '11':
                    obj = '待接单'
                    break;
            }
            return obj
        },
        workStatus(val) {
            let obj = ''
            switch (val) {
                case '00':
                    obj = '待派单'
                    break;
                case '01':
                    obj = '待自提'
                    break;
                case '02':
                    obj = '待取货'
                    break;
                case '03':
                    obj = '服务中'
                    break;
                case '04':
                    obj = '已完成'
                    break;
                case '05':
                    obj = '退款审核'
                    break;
                case '06':
                    obj = '退款关闭'
                    break;
                case '07':
                    obj = '待接单'
                    break;
            }
            return obj
        },
        orderType(val) {
            let obj = ''
            switch (val) {
                case '00':
                    obj = '普通支付订单'
                    break;
                case '01':
                    obj = '采购订单'
                    break;
            }
            return obj
        },
        orderSource(val) {
            let obj = ''
            switch (val) {
                case '00':
                    obj = '小程序'
                    break;
                case '01':
                    obj = 'APP'
                    break;
                case '02':
                    obj = '线下'
                    break;
            }
            return obj
        }
    },

} 